
import sys
import config
import app.tools as tool
from PyQt4 import QtCore, QtGui
from app.ui.icon import Icon


class Menu(object):

    def __init__(self, parent):
        self.parent = parent
        self.icon = Icon()
        menubar = QtGui.QMenuBar(parent)
        menubar.setObjectName(tool._from_utf8("menubar"))
        menu_menu = QtGui.QMenu(menubar)
        menu_menu.setTitle(tool._translate("MainWindow", "Menu", None))
        menu_menu.addAction('Connect', Menu.connect)
        menu_menu.addAction('Exit', lambda: sys.exit())
        menu_help = QtGui.QMenu(menubar)
        menu_help.setSeparatorsCollapsible(False)
        menu_help.setTitle(tool._translate("MainWindow", "Help", None))
        menu_help.addAction('Author', lambda: self.parent.tab.add_about())
        menu_help.addAction(self.icon.get(config.ICON_HELP), 'Help', lambda: self.parent.tab.add_help())
        menubar.addAction(menu_menu.menuAction())
        menubar.addAction(menu_help.menuAction())
        parent.setMenuBar(menubar)
        statusbar = QtGui.QStatusBar(parent)
        statusbar.setObjectName(tool._from_utf8("statusbar"))
        parent.setStatusBar(statusbar)

    @staticmethod
    def connect():
        print('connect')

    @staticmethod
    def init(parent=None):
        return Menu(parent)
